#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <ctime>
#include <cctype>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <deque>
#define _v putchar ('\n')
#define _e putchar (' ')
#define ll long long
#define mx(x,y) x>y?x:y
#define mn(x,y) x<y?x:y
#define INF 9999999999999999999ll
#define INE -9999999999999999999ll
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;
char c;
inline void r(int &a){
	a=0;
	while((c=getchar())<48);
	while(c>47) a=a*10+c-'0',c=getchar();
}
inline void wr(int x){
	if(x<0) x=-x,putchar(45);
	if(x<10) {
		putchar(x+48);
		return ;
	}
	wr(x/10);
	putchar(x%10+48);
}
inline int ksm(int a,int b,int m){
	int ans=1;
	while(b){
		if(b&1)
		    ans=ans*a%m;
		a=a*a%m;
		b>>=1;
	}
	return ans;
}//上面是模板，自动忽略。。。
const int N=1005,M=40005;
int n,a[N],mod=998244353,ans,now,f[N][M];
int main (){
	r(n);
	for(int i=1;i<=n;i++)
	    r(a[i]);
	for(int i=1;i<=n;i++) {
		ans=(ans+i)%mod;//累加
		for(int j=i-1;j>=1;j--) {
			now=a[i]-a[j];//公差
			ans=(ans+f[j][now+N])%mod;
			f[i][N+now]=(f[i][now+N]+f[j][now+N]+1)%mod;//状态转移方程
		}
	}
	wr(ans),_v;
	return 0;
}